fix(workflows): reject bool / .inf catalog priority in workflow & step catalog loaders#3526
Open
jawwad-ali wants to merge 1 commit into
Open
fix(workflows): reject bool / .inf catalog priority in workflow & step catalog loaders#3526jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
…catalog loaders
The WorkflowRegistry and StepRegistry catalog-config loaders coerced priority
with int() inside except (TypeError, ValueError), missing two guards the base
CatalogStackBase loader already has:
- bool is an int subclass, so 'priority: true' was silently coerced to 1;
- int(float('inf')) raises OverflowError (not caught), so 'priority: .inf'
crashed with an uncaught traceback.
Add the explicit bool check and OverflowError to both loaders, and add
OverflowError to the two _coerce_priority helpers used by 'catalog add' (they
return 0 on an uncoercible existing priority instead of crashing).
Parametrized tests on both TestWorkflowCatalog and TestStepCatalog reject
priority true/false/.inf (fail before: bool coerced to 1 / inf OverflowError).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Rejects boolean and infinite priorities in workflow and step catalog loaders while preventing catalog add from crashing on infinite existing priorities.
Changes:
- Adds explicit boolean validation and
OverflowErrorhandling. - Adds regression tests for loader validation.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/workflows/catalog.py |
Hardens priority parsing and add-catalog coercion. |
tests/test_workflows.py |
Tests invalid boolean and infinite priorities. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Medium
Comment on lines
+379
to
+380
| except (TypeError, ValueError, OverflowError): | ||
| # OverflowError: int(float("inf")) — a ``priority: .inf``. |
Comment on lines
+699
to
702
| except (TypeError, ValueError, OverflowError): | ||
| # OverflowError: int(float("inf")) — treat an uncoercible | ||
| # existing priority as 0 rather than crashing 'catalog add'. | ||
| return 0 |
Comment on lines
+1340
to
1343
| except (TypeError, ValueError, OverflowError): | ||
| # OverflowError: int(float("inf")) — treat an uncoercible | ||
| # existing priority as 0 rather than crashing 'catalog add'. | ||
| return 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
WorkflowRegistryandStepRegistrycatalog-config loaders parsedprioritywith:This misses two guards the base
CatalogStackBase._load_catalog_configalready has:intsubclass →priority: truewas silently coerced to1instead of rejected.int(float("inf"))raisesOverflowError(not in the tuple) →priority: .infcrashed with an uncaught traceback instead of the cleanexpected integererror.The two
_coerce_priorityhelpers used bycatalog add(to compute the next priority) had the sameOverflowErrorgap.Fix
Add the explicit
boolcheck andOverflowErrorto both loaders (mirroring the base loader), andOverflowErrorto both_coerce_priorityhelpers (they return0for an uncoercible existing priority rather than crashingcatalog add).Test
Parametrized
test_config_priority_bool_or_inf_rejectedon bothTestWorkflowCatalogandTestStepCatalogrejectspriority: true/false/.inf— fails before (bool coerced to 1 / infOverflowError), passes after.🤖 Written with the assistance of Claude Code (AI). Bug self-found; fix/tests verified locally (fail-before / pass-after), ruff clean.